<%= form_for @changeset, @action, [class: "ui form", multipart: true], fn f -> %>
  <div class="two fields">
    <div class="field required <%= AdminHelpers.error_class(f, :name) %>">
      <%= label(f, :name, "Name") %>
      <%= text_input(f, :name, placeholder: "Ruby on Rails") %>
      <%= AdminHelpers.error_message(f, :name) %>
    </div>

    <div class="field required <%= AdminHelpers.error_class(f, :slug) %>">
      <%= label(f, :slug, "Slug") %>
      <%= text_input(f, :slug, placeholder: "ror", readonly: f.data.id) %>
      <%= AdminHelpers.error_message(f, :slug) %>
    </div>
  </div>

  <div class="two fields">
    <div class="field <%= AdminHelpers.error_class(f, :twitter_handle) %>">
      <%= label(f, :twitter_handle, "Twitter Handle") %>
      <%= text_input(f, :twitter_handle, placeholder: "RubyOnRails", mask: "slug") %>
      <%= AdminHelpers.error_message(f, :twitter_handle) %>
    </div>

    <div class="field <%= AdminHelpers.error_class(f, :website) %>">
      <%= label(f, :website, "Website") %>
      <%= text_input(f, :website, placeholder: "https://www.rubyonrails.org") %>
      <%= AdminHelpers.error_message(f, :website) %>
    </div>
  </div>

  <div class="field <%= AdminHelpers.error_class(f, :description) %>">
    <label for="description">
      Description
      <%= AdminHelpers.help_icon("140 characters or less.") %>
    </label>
    <%= textarea(f, :description, placeholder: "Ruby on Rails (Rails) is a web application framework written in Ruby. It is meant to help simplify the building of complex websites.", rows: 2) %>
    <%= AdminHelpers.error_message(f, :description) %>
  </div>

  <div class="two fields">
    <div class="fourteen wide field">
      <label for="icon">
        Icon
        <%= AdminHelpers.help_icon("Ideal size is 600px by 600px") %>
        <%= AdminHelpers.file_toggle_buttons() %>
      </label>
      <%= AdminHelpers.error_message(f, :icon) %>
      <%= file_input f, :icon %>
    </div>

    <div class="two wide field">
      <img src="<%= ChangelogWeb.TopicView.icon_url(f.data, :small) %>" height=66>
    </div>
  </div>

  <div class="ui hidden divider"></div>
  <div class="ui equal width stackable grid">
  <%= if !AdminHelpers.is_persisted(f.data) do %>
    <div class="column"><%= AdminHelpers.submit_button(:primary, "Create") %></div>
    <div class="column"><%= AdminHelpers.submit_button(:secondary, "Create and Close", AdminHelpers.next_param(@conn, Routes.admin_topic_path(@conn, :index))) %></div>
  <% else %>
    <div class="column"><%= AdminHelpers.submit_button(:primary, "Save", "edit") %></div>
    <div class="column"><%= AdminHelpers.submit_button(:secondary, "Save and Close", AdminHelpers.next_param(@conn)) %></div>
  <% end %>
    <div class="column"></div>
  </div>
<% end %>
